package com.yonyou.cyxdms.basedata.service.controller.salestaskset;


import com.yonyou.cyxdms.basedata.client.dto.SalesTaskDTO;
import com.yonyou.cyxdms.basedata.service.dto.salestaskset.SalesTaskSetDTO;
import com.yonyou.cyxdms.basedata.service.service.salestaskset.SalesTaskSetService;
import com.yonyou.cyxdms.basedata.client.domains.vo.SalesTaskSetVO;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 销售顾问-销售任务设置
 *
 * @author：chenzb
 * @since：2019-11-19
 */
@Api(value = "销售顾问-销售任务设定", tags = {"销售顾问-销售任务设置相关接口"})
@RestController
@RequestMapping("/bastDataParams/consultantSalesTask")
public class SalesTaskSetController {

    @Autowired
    private SalesTaskSetService salesTaskSetService;


    /**
     * fegin - 查询销售任务目标
     *
     * @author chenzb
     * @since 2019/11/19
     */
    @ApiOperation(value = "查询销售顾问-销售任务目标")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    @GetMapping("/getConsultantSalesTaskList")
    public List<SalesTaskSetVO> getConsultantSalesTaskList(SalesTaskDTO salesTaskDTO) {
        return salesTaskSetService.getConsultantSalesTaskList(salesTaskDTO.getConsultantIds(), salesTaskDTO.getCheckDate());
    }

    /**
     * 新增/更新销售顾问月销售任务
     *
     * @author chenzb
     * @since 2019/11/19
     */
    @ApiOperation(value = "新增/更新销售顾问月销售任务")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    @PostMapping("/addConstantMonthSalesTask")
    public Integer addConstantMonthSalesTask(@RequestBody SalesTaskSetDTO salesTaskSetDTO){
        return salesTaskSetService.addConstantMonthSalesTask(salesTaskSetDTO);
    }


    /**
     * 设置销售任务目标 - 前端设置
     *
     * @author chenzb
     * @since 2019/11/19
     */
    @ApiOperation(value = "前端-设置销售顾问-销售任务目标")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    @GetMapping("/getConsultantSalesTaskDetail")
    public List<SalesTaskSetVO> getConsultantSalesTaskDetail(@RequestParam(value = "consultantId", required = false) String consultantId,
                                                             @RequestParam(value = "checkDate") String checkDate,
                                                             @RequestParam(value = "orgId", required = false) String orgId) {
        return salesTaskSetService.getConsultantSalesTaskDetail(consultantId, checkDate, orgId);
    }

}